import numpy as np
import onnxruntime
import onnx
import torch
from main import RealToOnehot
def to_numpy(tensor):
    return tensor.detach().cpu().numpy() if tensor.requires_grad else tensor.cpu().numpy()
model = onnx.load('./bid.onnx')
onnx.checker.check_model(model)
model = onnxruntime.InferenceSession('./bid.onnx')
input_name = model.get_inputs()[0].name
output_name = model.get_outputs()[0].name
input_data = '2222333344445555D'
input_data = RealToOnehot(input_data)
input_data = torch.flatten(input_data)
print(type(input_data))
input_data = np.array((input_data))
input_data = np.transpose(input_data)
print(input_data.shape)
print(type(input_data))
out = model.run(output_names=[output_name], input_feed={input_name: input_data})
print(input_data)
print(out)